#include <stdio.h>
#include <math.h>
int isPrime(int n)
{
	if(n==2 || n==3 || n==5 || n==7)return 1;
	if(n%2==0 || n%3==0 || n==1)return 0;
	int i;
	for (i=5; i<=floor(sqrt(n)); i+=6) {
		if (n%i == 0 || n%(i+2)==0)return 0;
	}
	return 1;
}

int threeRepeat(int n)
{
	int a[10]={0}, i=0;
	while(n) {
		a[n%10]++;
		n /=10;
	}
	i=0;
	while(i<10) {
		if (a[i++] >= 3)return 1;
	}
	return 0;
}
int main()
{
	printf("%d\n", isPrime(12));
	int i;
	for (i=100001; i<299993; i+=2) {
		if (isPrime(i) && threeRepeat(i)) {
			printf("%d ", i);
		}
	}
}
